package com.fone.player.util;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.fone.player.activity.personal.RegistActivity;
import com.fone.player.activity.personal.UserInfoActivity;
import com.fone.player.billing.impl.FonePayManager;
import com.fone.player.billing.util.FoneConstants;
import com.fone.player.entity.RedirectInfo;
import com.fone.player.sns.UserInfoManager;

public class WebViewAction {
	
	private Context context;

	public WebViewAction(Context context) {
		super();
		this.context = context;
	}

	/** 日志标签 */
	private static final String TAG = "WebViewAction";
	
	
	/** 
	 * 播放视频
	 */
	public void play(String utp, String vgurl){
		L.v(TAG, "play", "-utp:-"+utp+"-vgurl:-"+vgurl);
		if(!TextUtils.isEmpty(utp) && !TextUtils.isEmpty(vgurl)){
			
			RedirectInfo info = new RedirectInfo();
			info.utp = new Integer(utp);
			info.url = vgurl;
			info.vgurl = vgurl;
			info.xyzplayurl = vgurl;
			Activity2poster.startActivity(context, info);
		}
	}
	
	/** 
	 * 登录
	 */
	public void login(){
		L.v(TAG, "login", "-login-");
		
		// 个人信息
		if (UserInfoManager.isLogin()) {
			Intent intent = new Intent(context, UserInfoActivity.class);
			context.startActivity(intent);
		} else {
			FoneUtil.toLoginPage(context, "1");// 1 点击头像进入的登录页
		}
	}
	
	/** 
	 * 注册
	 */
	public void register(){
		L.v(TAG, "register", "-register-");
	
		if (UserInfoManager.isLogin()) {
			Intent intent = new Intent(context, UserInfoActivity.class);
			context.startActivity(intent);
		} else {
			Intent intent = new Intent(context, RegistActivity.class);
			context.startActivity(intent);
		}
	}
	
	/** 
	 * 加入Vip
	 */
	public void vip(){
		L.v(TAG, "register", "-register-");
		
		FonePayManager mFonePayManger = FonePayManager.getInstance();
		mFonePayManger.startPay(FoneConstants.DO_VIP_ACTION,
				FoneConstants.FROM_VIP_PAGE_BUTTON,FoneConstants.FEE_FROM_ACTIVITY,"");

	}
	
}
